{% extends 'base.html' %}
{% block css %}
<link href="/static/css/dataTables.bootstrap.min.css" rel="stylesheet">
<link href="/static/css/bootstrap-switch.min.css" rel="stylesheet">

{% endblock %}
{% block content %}
<div class="right_col" role="main">
    <div class="">
        <div class="clearfix"></div>
        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                    <div class="x_title">
                        <div class="loading"></div>
                        <h2>文件上传 </h2>
                        <div class="clearfix"></div>
                    </div>

                <div class="form-group">
                    <label for="exampleInputFile">附件上传</label>
                     <input  type="file" name="file" id="file_upload">
                    <strong style="color: #90111A;">上传路径:</strong>
                    <select name="mytext" id="select_id">
                            <option value="vue/static/">vue/static/</option>
                            <option value="loan/">loan/</option>
                            <option value="loan/doujinda/">loan/doujinda/</option>
                            <option value="loan/qianyiyou/">loan/qianyiyou/</option>
                            <option value="vue/bd/static/">vue/bd/static/</option>
                            <option value="vue/bd/images/1520400963149/">vue/bd/images/1520400963149/</option>
                            <option value="apk/">apk/</option>
                            <option value="vue/image/">vue/image/</option>
                            <option value="html/">html/</option>
                            <option value="ftp_test/">ftp_test/</option>
                            <option value="image/">image/</option>
                            <option value="activeimg/">activeimg/</option>
                            <option value="image/distribution/">image/distribution/</option>
                            <option value="image/distribution/banner/">image/distribution/banner/</option>
                    </select>

                     <button  type="button" class="btn btn-default" onclick="FileUpload()">上传</button>
                </div>
                <div class="modal fade" id="wrongpwd-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                    &times;
                                </button>
                                <h4 class="modal-title" id="myModalLabel">
                                    提示
                                </h4>
                            </div>
                            <div class="modal-body" id="wrongpwd-modal-body"></div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-primary"  onclick="sucess_direct()" data-dismiss="modal">确定
                                </button>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal -->
                </div>

             </div>

        </div>
    </div>
</div>


{% endblock %}
{% block js %}
<script src="/static/js/jquery.dataTables.min.js"></script>
<script src="/static/js/dataTables.bootstrap.min.js"></script>
<script src="/static/js/display_select.js"></script>
<script src="/static/js/bootstrap-switch.min.js"></script>

<script type="text/javascript">

     function FileUpload() {
            var form_data = new FormData();
            var file_info = $('#file_upload')[0].files[0];
            var checkText=$("#select_id").val()
            form_data.append('checkText',checkText);
            form_data.append('file',file_info);

            // 提交ajax的请求
            $.ajax({
                url:"/op/ftp_file_upload",
                type:'POST',
                data: form_data,
                processData: false,
                contentType: false,
                dataType: 'json',
                success: function(data) {
                    if (data.res) {
                        var res_addr = "CDN地址:"+ "<u><a href='####'>" + data.data  +"</a></u>"
                        var res_msg = "上传结果:"+ "<strong>" + data.msg  +"</strong>"
                        $('#wrongpwd-modal-body').html(res_msg + "</br>" + res_addr);

				        $('#wrongpwd-modal').modal({
        			    keyboard: true

    			});
                    }
                    else {
                        alert(data.msg)
                    }
                }
            });
        }
    function sucess_direct() {
            $(location).attr('href','/op/ftp_file_upload');
    }




//



    </script>


{% endblock %}